package com.xzc.shopping.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.xzc.shopping.common.BaseResponse;
import com.xzc.shopping.model.domain.Cart;
import com.xzc.shopping.model.dto.CartAddDTO;
import com.xzc.shopping.model.vo.CartListVO;
import com.xzc.shopping.model.vo.CartVO;
import org.springframework.transaction.annotation.Transactional;

import javax.validation.Valid;
import java.util.List;

/**
* @author Administrator
* @description 针对表【cart】的数据库操作Service
* @createDate 2025-02-26 11:15:14
*/
public interface CartService extends IService<Cart> {


    BaseResponse<List<CartVO>> getCartList(Integer id);

    BaseResponse<Boolean> addCartItem(Integer id, @Valid CartAddDTO dto);

    BaseResponse<Boolean> deleteCartItem(Integer id, Long cartId);

    // 更新数量（带乐观锁）
    @Transactional
    BaseResponse<CartListVO> updateQuantity(Integer userId, Long cartId, Integer quantity);
}
